﻿using System.IO;

/// <summary>
/// 浮点型的
/// </summary>
public class Vector2Field : FieldBase
{
    public Vector2Field(string className, string desc, string type, string name)
        : base(className, desc, type, name) { }

    public override string F_Type { get { return "Vector2"; } }
    /// <summary>
    /// 写入GUI
    /// </summary>
    public override void WriteGUI(int indentLevel, StreamWriter SW)
    {
        string str = "ReflectionTools.SetNonPublicField(data, \"_{0}\", EditorGUILayout.Vector2Field(\"{1}\", ReflectionTools.GetNonPublicField<{2}>(data, \"_{0}\")));".SafeFormat(F_Name, F_Desc, F_Type, F_Name);
        SW.WriteLine(GetIndent(indentLevel) + str);
        //SW.WriteLine(GetIndent(indentLevel) + "_{0} = EditorGUILayout.Vector2Field(\"{1}\", _{2});".SafeFormat(F_Name, F_Desc, F_Name));
    }

    /// <summary>
    /// 写入获取数据代码
    /// </summary>
    public override void WriteGetData(int indentLevel, StreamWriter SW, bool isEnd)
    {
        string endStr = isEnd ? string.Empty : ",";
        SW.WriteLine(GetIndent(indentLevel) + "eReader.GetData(i, \"{0}\").SafeToVector2(){1} // {2}".SafeFormat(F_Name, endStr, F_Desc));
    }

    public override string ExportDataStr()
    {
        return "data.{0}.x + \",\" + data.{1}.y".SafeFormat(F_Name, F_Name);
    }
}
